home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_HitDetect / DrawingViewWraps.psw < prev    next >
Encoding:
Text File  |  1992-12-19  |  3.3 KB  |  127 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34. *    DetectViewWraps.psw
  35. *
  36. *    The wraps used to check for hit detection, draw the control points
  37. *    and lines and create the control points font.
  38. */
  39.  
  40. defineps PSWSetUpath (float numstring Pts[Tot_Pts]; int Tot_Pts;
  41.                     char Ops[Tot_Ops]; int Tot_Ops)
  42.     [Pts (Ops)]
  43. endps
  44.  
  45. defineps PSWUpathStroke(userobject UPath)
  46.     UPath ustroke
  47. endps
  48.  
  49. /*
  50.  *  The return value, Hit, is the result of the inustroke
  51.  *  operation, either true or false.
  52.  */
  53. defineps PSWHitPath(float numstring HPts[Tot_HPts]; int Tot_HPts;
  54.     char HOps[Tot_HOps]; int Tot_HOps; float numstring Pts[Tot_Pts];
  55.     int Tot_Pts; char Ops[Tot_Ops]; int Tot_Ops | boolean *Hit)
  56.     [HPts (HOps)]  [Pts (Ops)] inustroke  Hit
  57. endps
  58.  
  59. defineps PSWDrawControlPoints (float X, Y; float numstring Pts[Tot_Pts]; int Tot_Pts; char *Chs)
  60.     X Y moveto  (Chs) Pts xyshow
  61. endps
  62.  
  63. /*
  64. *  The sa and rsa procedures ensure that the first character is drawn correctly
  65. *  with respect to device space. It's not so much an issue with square 
  66. *  images but can be quite significant with other shapes.
  67. */
  68. defineps PSWDefineFont(char *fontname)
  69.     10 dict dup begin
  70.     /sa { % x y  sa  x' y'
  71.         transform
  72.         0.25 sub round 0.25 add exch
  73.         0.25 sub round 0.25 add exch
  74.         itransform
  75.     } bind def
  76.  
  77.     /rsa { %dx dy  rsa  dx' dy'
  78.         dtransform
  79.         round exch
  80.         round exch
  81.         idtransform
  82.     } bind def
  83.  
  84.     /FontName /fontname def
  85.     /FontType 3 def
  86.     /FontMatrix [.001 0 0 .001 0 0] def
  87.     /FontBBox [-500 -500 500 500] def
  88.  
  89.     /Encoding 256 array def
  90.         0 1 255 {Encoding exch /.notdef put} for
  91.     
  92.     Encoding
  93.         dup (a) 0 get /Rectfill put
  94.         (b) 0 get /Rectopen put
  95.     
  96.     /CharProcs 3 dict def
  97.     CharProcs begin
  98.         /.notdef { } def
  99.         /Rectfill
  100.         {
  101.             -300 -300 sa moveto 0 600 rsa rlineto
  102.             600 0 rsa rlineto 0 -600 rsa rlineto closepath
  103.             fill
  104.         } def
  105.         /Rectopen
  106.         {
  107.             -300 -300 sa moveto 0 600 rsa rlineto
  108.             600 0 rsa rlineto 0 -600 rsa rlineto closepath
  109.             stroke
  110.         } def
  111.     end
  112.     
  113.     /BuildChar
  114.     {
  115.         500 0 -500 -500 500 500 setcachedevice
  116.         exch begin
  117.             Encoding exch get
  118.             CharProcs exch get
  119.             exec
  120.         end
  121.     } def
  122.   end
  123.   
  124.   /fontname exch definefont pop
  125. endps
  126.  
  127.